package com.surveypark.struts2.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.surveypark.domain.Survey;
import com.surveypark.domain.User;
import com.surveypark.service.SurveyService;

@Controller("moveOrCopyPageAction")
@Scope("prototype")
public class MoveOrCopyPageAction extends BaseAction<Survey> implements UserAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8974775995107938248L;
	private Integer srcPid;
	private List<Survey> surveys;
	private Integer targPid;
	private int pos;
	private Integer sid;
	public Integer getSid() {
		return sid;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}

	public Integer getTargPid() {
		return targPid;
	}

	public void setTargPid(Integer targPid) {
		this.targPid = targPid;
	}

	public int getPos() {
		return pos;
	}

	public void setPos(int pos) {
		this.pos = pos;
	}

	private User user;
	public Integer getSrcPid() {
		return srcPid;
	}

	public void setSrcPid(Integer srcPid) {
		this.srcPid = srcPid;
	}

	public List<Survey> getSurveys() {
		return surveys;
	}

	public void setSurveys(List<Survey> surveys) {
		this.surveys = surveys;
	}

	@Resource(name="surveyService")
	private SurveyService surveyService;
	
	
	public String toSelectTargetPage(){
		this.surveys = surveyService.findSurveysWidthPage(user);
		return "moveOrCopyPageListPage";
	}
	
	public String doMoveOrCopyPage(){
		this.surveyService.moveOrCopyPage(srcPid, targPid, pos);
		return "designSurveyAction" ;
	}
	
	@Override
	public void setUser(User user) {
		// TODO Auto-generated method stub
		this.user = user;
	}	
}
